package dreamCookGame.chickenMiniGame;

public class Vector {
	private float _x;
	private float _y;
	private float _z;
	
	Vector(float x, float y, float z){
		_x = x;
		_y = y;
		_z = z;
	}
	
	Vector(float x, float y){
		_x = x;
		_y = y;
		_z = 0;
	}
	
	public float getX(){
		return _x;
	}
	public float getY(){
		return _y;
	}
	public float getZ(){
		return _z;
	}
	
	public void setX(float x){
		_x = x;
	}
	public void setY(float y){
		_y = y;
	}
	public void setZ(float z){
		_z = z;
	}
	
	public float getSquareMagnitude(){
		return ((_x*_x)+(_y*_y)+(_z*_z));
	}
	public float getMagnitude(){
		return ((float)Math.sqrt(this.getSquareMagnitude()));
	}
	
	public void normalize(){
		float mag = this.getMagnitude();
		if(mag!=0){
			_x = _x/mag;
			_y = _y/mag;
			_z = _z/mag;
		}else{
			_x = 0;
			_y = 0;
			_z = 0;
			
		}
	}

	public void add(Vector vector) {
		_x+=vector.getX();
		_y+=vector.getY();
		_z+=vector.getZ();
	}
	public void subtract(Vector vector) {
		_x-=vector.getX();
		_y-=vector.getY();
		_z-=vector.getZ();
	}

	public void scale(float scalar) {
		_x *= scalar;
		_y *= scalar;
		_z *= scalar;
	}
	public String toString(){
		return ("("+_x+","+_y+","+_z+")");
	}

	public void set(int x, int y) {
		_x=x;
		_y=y;
		_z=0;
	}
	public void set(int x, int y, int z) {
		_x=x;
		_y=y;
		_z=z;
	}

	public void setMagnitude(float mag) {
		this.normalize();
		this.scale(mag);
	}

	public double getDirection() {
		return (Math.atan2(_x, _y)+Math.PI);
	}
}